# -*- coding: utf-8 -*-
# @Time    : 2022/7/16 0:32
# @Author  : catherine
# @Email   : catherine_csq@163.com
# @File    : base_case.py
# @Software: PyCharm
import os
import unittest
from time import sleep

from pages.login_page import LoginPage
from tools.tools import chrome_driver
from tools.tools_crm_khgl import read_data
from config.config import DATAS_PATH

class BaseCase(unittest.TestCase):
    '''测试用例基类'''

    datas = read_data(os.path.join(DATAS_PATH, "crm_khgl_data.xls"))

    def setUp(self) -> None:
        '''启动浏览器，窗口最大化，访问网址'''

        data=self.datas[0]
        username = data[0]
        password = data[1]
        # 打开界面，实例化chrome_driver对象
        self.driver = chrome_driver()
        # 实例化LoginPage对象
        lp = LoginPage(self.driver)
        # 访问登录页
        lp.open()
        # 输入用户名
        lp.input_username(username)
        # 输入密码
        lp.input_password(password)
        # 点击登录
        lp.click_login_btn()
        sleep(2)


    def tearDown(self) -> None:
        sleep(2)
        self.driver.quit()

